/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package regras;

import Interfaces.CheckerRule;

/**
 *
 * @author Tainá, Ana Luiza e Amanda
 */
public class RuleNumberSequence02 implements CheckerRule{
    private String password;
    public RuleNumberSequence02(String password) {
        this.password = password;
    }
    
    @Override
    public int rule(){
        String number = "01234567890"; 
        int total = 0;
        int sequenceNumber = 0;
        for (int s=0; s < 8; s++) { 
             String aFwd = number.substring(s,s+3); 
             String aRev = new StringBuffer(aFwd).reverse().toString(); 
             if (password.toLowerCase().indexOf(aFwd) != -1 || password.toLowerCase().indexOf(aRev) != -1)
                  sequenceNumber++;
        }
        if (sequenceNumber >0)
            total -= sequenceNumber * 3;
        
        return total; 
   }
}
